package com.wuzf.exception;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authc.UnknownAccountException;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

public class MyExceptionHandler implements HandlerExceptionResolver{

	
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
			Exception ex) {
		
		Map<String, Object> map = new HashMap<String, Object>();
		System.out.println("记录错误信息：" + ex);
		map.put("ex", ex);
		
		
		//根据不同的错误转向不同 的页面
		if (ex instanceof UnknownAccountException) {
			return new ModelAndView("jsp/accountError", map);
		} else {
			return new ModelAndView("jsp/error", map);
		}
	}
	
}
